/**
 * Animation 类的扩展
 */

import { Animation } from 'cc';

declare module 'cc' {
    interface Animation {
        /**
         * 获得当前正在播放 或 最后一次播放过的动画剪辑名称 从未播放过的话默认是 undefined
         */
        get lastPlayed(): string | undefined;

        /**
         * 获得动画剪辑名称列表
         */
        get clipNameList(): string[] | undefined;
    }
}

Object.defineProperty(Animation.prototype, "lastPlayed", {
    get: function () {
        return this._crossFade?._managedStates?.[0]?.state?.name;
    },

    enumerable: true,
    configurable: true
});

Object.defineProperty(Animation.prototype, "clipNameList", {
    get: function () {
        return this._nameToState ? Object.keys(this._nameToState) : undefined;
    },

    enumerable: true,
    configurable: true
});